load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@rules_cc//cc:defs.bzl", "cc_library")

bool_flag(
    name = "use_mbedtls",
    build_setting_default = False,
)

config_setting(
    name = "use_mbedtls_setting",
    flag_values = {":use_mbedtls": "true"},
    visibility = ["//:__subpackages__"],
)

cc_library(
    name = "config",
    visibility = ["//:__subpackages__"],
    defines = select({
        "//:use_mbedtls_setting": [
            "HAVE_LIBMBEDCRYPTO",
            "HAVE_MBEDTLS_AES_H",
            "HAVE_MBEDTLS_MD_H",
            "HAVE_MBEDTLS_PKCS5_H",
        ],
        "//conditions:default": [],
    }),
    hdrs = select({
        "@platforms//os:windows": ["libarchive_bazel_windows_config.h"],
        "//conditions:default": ["libarchive_bazel_generic_config.h"],
    }),
)
